﻿<phone:PhoneApplicationPage 
    x:Class="TodayHumor.Read"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:local="clr-namespace:TodayHumor"
    xmlns:phone="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone"
    xmlns:shell="clr-namespace:Microsoft.Phone.Shell;assembly=Microsoft.Phone"
    xmlns:controls="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone.Controls"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
    xmlns:toolkit="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone.Controls.Toolkit"
    mc:Ignorable="d" d:DesignWidth="480" d:DesignHeight="728"
    FontFamily="{StaticResource PhoneFontFamilyNormal}"
    FontSize="{StaticResource PhoneFontSizeNormal}"
    Foreground="{StaticResource PhoneForegroundBrush}"
    SupportedOrientations="Portrait"  Orientation="Portrait"
    shell:SystemTray.BackgroundColor="{StaticResource PhoneAccentColor}"
    shell:SystemTray.ForegroundColor="WhiteSmoke"
    shell:SystemTray.IsVisible="True">

    <!--<phone:PhoneApplicationPage.Resources>
        <local:UriToImageConverter x:Key="UriToImageConverter"/>
    </phone:PhoneApplicationPage.Resources>-->

    <Grid x:Name="LayoutRoot" Background="Transparent" Language="ko-kr">
        <Grid Height="110" VerticalAlignment="Top">
            <TextBlock FontSize="54" x:Name="TitleTB"
                       VerticalAlignment="Bottom" Margin="15,0,0,15"/>
        </Grid>
        <controls:Pivot x:Name="pivot" Margin="0,110,0,0" Background="#202020"
                        SelectionChanged="PivotSelectionChanged">
            <!-- 게시글 리스트 피벗 아이템 -->
            <controls:PivotItem>
                <StackPanel Margin="0,0,10,0">
                    <ListBox x:Name="lbArticleList" Height="560" Margin="5,0,0,0"
                             Loaded="LongListSelectorLoaded" SelectionChanged="ArticleListSelectorSelectionChanged">
                        <ListBox.ItemTemplate>
                            <DataTemplate>
                                <StackPanel Width="440" Margin="0,0,0,15" toolkit:TiltEffect.IsTiltEnabled="True">
                                    <StackPanel Orientation="Horizontal" Margin="0,0,0,10" Width="440">
                                        <StackPanel Width="340" Margin="5,0,5,5">
                                            <TextBlock Text="{Binding Title}" FontSize="24" TextWrapping="Wrap" Margin="0,0,0,10"/>
                                            <StackPanel Orientation="Horizontal" Margin="5,0,0,0">
                                                <Image Height="20">
                                                    <Image.Source>
                                                        <BitmapImage UriSource="{Binding Board}"/>
                                                    </Image.Source>
                                                </Image>
                                                <TextBlock Text="{Binding Writer}" Foreground="Gray" Margin="8,-1,7,0"/>
                                            </StackPanel>
                                        </StackPanel>
                                        <StackPanel Width="85">
                                            <TextBlock Text="{Binding Like}" Foreground="{StaticResource PhoneAccentBrush}" FontWeight="Bold"
                                                       FontSize="24" TextAlignment="Right"/>
                                            <TextBlock Text="{Binding Comments}" Foreground="{StaticResource PhoneAccentBrush}" TextAlignment="Right"/>
                                        </StackPanel>
                                    </StackPanel>
                                    <Rectangle Height="2" HorizontalAlignment="Stretch" Fill="{StaticResource PhoneForegroundBrush}" Opacity=".3"/>
                                </StackPanel>
                            </DataTemplate>
                        </ListBox.ItemTemplate>
                    </ListBox>
                </StackPanel>
            </controls:PivotItem>
            <!-- 게시글 내용 피벗 아이템 -->
            <controls:PivotItem>
                <ListBox x:Name="lbArticleContent" Margin="5,0,0,0">
                    <ListBox.ItemTemplate>
                        <DataTemplate>
                            <local:ArticleTemplateSelector Content="{Binding}">
                                <local:ArticleTemplateSelector.Title>
                                    <DataTemplate>
                                        <StackPanel Margin="0,0,0,25" Width="440">
                                            <StackPanel Orientation="Horizontal" Margin="0,0,0,10">
                                                <TextBlock Text="작성자" Foreground="Gray" Margin="0,0,5,0"/>
                                                <TextBlock Text="{Binding Writer}" FontWeight="Bold" Foreground="Gray" Margin="0,0,10,0"/>
                                                <TextBlock Text="추천/반대" Foreground="Gray" Margin="0,0,5,0"/>
                                                <TextBlock Text="{Binding LikeDislike}" FontWeight="Bold" Foreground="Gray" Margin="0,0,10,0"/>
                                                <TextBlock Text="{Binding Mobile}" Foreground="Gray" FontWeight="Bold"/>
                                            </StackPanel>
                                            <TextBlock Text="{Binding Title}" FontSize="28" TextWrapping="Wrap" Margin="0,0,0,15" Foreground="{StaticResource PhoneForegroundBrush}"/>
                                            <Rectangle Fill="{StaticResource PhoneForegroundBrush}" Opacity=".3" Height="2" HorizontalAlignment="Stretch"/>
                                        </StackPanel>
                                    </DataTemplate>
                                </local:ArticleTemplateSelector.Title>
                                <local:ArticleTemplateSelector.ArticleContent>
                                    <DataTemplate>
                                        <StackPanel Width="440">
                                            <toolkit:ContextMenuService.ContextMenu>
                                                <toolkit:ContextMenu Language="ko-kr">
                                                    <toolkit:MenuItem Header="이 줄 복사하기"/>
                                                    <toolkit:MenuItem Header="이 게시글 전체 복사하기"/>
                                                </toolkit:ContextMenu>
                                            </toolkit:ContextMenuService.ContextMenu>
                                            <TextBlock Text="{Binding Content}" Foreground="{StaticResource PhoneForegroundBrush}" FontSize="24" Padding="0,8" TextWrapping="Wrap" HorizontalAlignment="Left"/>
                                        </StackPanel>
                                    </DataTemplate>
                                </local:ArticleTemplateSelector.ArticleContent>
                                <local:ArticleTemplateSelector.CommentsAndDate>
                                    <DataTemplate>
                                        <StackPanel Width="440" Margin="0,0,0,0">
                                            <Grid Width="440" Margin="0,25,0,20">
                                                <StackPanel Orientation="Horizontal" HorizontalAlignment="Right">
                                                    <TextBlock Text="작성일" Foreground="Gray" Margin="0,0,5,0"/>
                                                    <TextBlock Text="{Binding Date}" FontWeight="Bold" Foreground="Gray"/>
                                                </StackPanel>
                                            </Grid>
                                            <Rectangle Fill="{StaticResource PhoneForegroundBrush}" Opacity=".3" Height="2" HorizontalAlignment="Stretch"/>
                                            <StackPanel Orientation="Horizontal" Margin="0,20,0,0">
                                                <TextBlock Text="댓글수" Foreground="Gray" Margin="0,0,5,0"/>
                                                <TextBlock Text="{Binding Comments}" FontWeight="Bold" Foreground="Gray"/>
                                            </StackPanel>
                                        </StackPanel>
                                    </DataTemplate>
                                </local:ArticleTemplateSelector.CommentsAndDate>
                                <local:ArticleTemplateSelector.Link>
                                    <DataTemplate>
                                        <HyperlinkButton Content="{Binding LinkContent}" NavigateUri="{Binding Link}" TargetName="_blank" HorizontalAlignment="Stretch" Margin="0" Padding="10"/>
                                    </DataTemplate>
                                </local:ArticleTemplateSelector.Link>
                                <local:ArticleTemplateSelector.Image>
                                    <DataTemplate>
                                        <Grid Width="440"  Loaded="ArticlePartGridLoaded">
                                            <toolkit:GestureService.GestureListener>
                                                <toolkit:GestureListener Tap="ContentImageTap"/>
                                            </toolkit:GestureService.GestureListener>
                                            <StackPanel Margin="0,10,0,10">
                                                <TextBlock Text="이미지를 로드하는 중.." FontSize="24" Foreground="{StaticResource PhoneAccentBrush}" FontWeight="Bold" Margin="0,0,0,5"/>
                                                <TextBlock Foreground="{StaticResource PhoneAccentBrush}" TextWrapping="Wrap" Opacity=".8"/>
                                            </StackPanel>
                                        </Grid>
                                    </DataTemplate>
                                </local:ArticleTemplateSelector.Image>
                                <local:ArticleTemplateSelector.Comment>
                                    <DataTemplate>
                                        <StackPanel Width="440" Margin="0,25,0,0">
                                            <toolkit:ContextMenuService.ContextMenu>
                                                <toolkit:ContextMenu Language="ko-kr">
                                                    <toolkit:MenuItem Header="이 댓글 추천"/>
                                                    <toolkit:MenuItem Header="이 댓글 반대"/>
                                                    <toolkit:MenuItem Header="이 댓글 전체 복사하기"/>
                                                </toolkit:ContextMenu>
                                            </toolkit:ContextMenuService.ContextMenu>
                                            <StackPanel Orientation="Horizontal" Margin="0,0,0,5">
                                                <TextBlock Text="{Binding CommentWriter}" Margin="0,0,10,0" Foreground="Gray" FontSize="26"/>
                                                <TextBlock Text="{Binding CommentLikeDislike}" Foreground="{StaticResource PhoneAccentBrush}" FontWeight="Bold" VerticalAlignment="Bottom" FontSize="24"/>
                                            </StackPanel>
                                        </StackPanel>
                                    </DataTemplate>
                                </local:ArticleTemplateSelector.Comment>
                                <local:ArticleTemplateSelector.CommentContent>
                                    <DataTemplate>
                                        <StackPanel Width="440">
                                            <toolkit:ContextMenuService.ContextMenu>
                                                <toolkit:ContextMenu Language="ko-kr">
                                                    <toolkit:MenuItem Header="이 댓글 추천"/>
                                                    <toolkit:MenuItem Header="이 댓글 반대"/>
                                                    <toolkit:MenuItem Header="이 줄 복사하기"/>
                                                    <toolkit:MenuItem Header="이 댓글 전체 복사하기"/>
                                                </toolkit:ContextMenu>
                                            </toolkit:ContextMenuService.ContextMenu>
                                            <TextBlock Text="{Binding Content}" Foreground="{StaticResource PhoneForegroundBrush}" FontSize="24" TextWrapping="Wrap" HorizontalAlignment="Left"/>
                                        </StackPanel>
                                    </DataTemplate>
                                </local:ArticleTemplateSelector.CommentContent>
                                <local:ArticleTemplateSelector.Write>
                                    <DataTemplate>
                                        <toolkit:PhoneTextBox x:Name="CommentTextBox" Hint="댓글 작성하기" Width="460" AcceptsReturn="True" Margin="-15,20,0,0"
                                                              Loaded="CommentTextBoxLoaded" GotFocus="CommentTextBoxGotFocus" LostFocus="CommentTextBoxLostFocus" TextChanged="CommentTextBoxTextChanged"/>
                                    </DataTemplate>
                                </local:ArticleTemplateSelector.Write>
                            </local:ArticleTemplateSelector>
                        </DataTemplate>
                    </ListBox.ItemTemplate>
                </ListBox>
            </controls:PivotItem>
        </controls:Pivot>
    </Grid>

    <phone:PhoneApplicationPage.ApplicationBar>
        <shell:ApplicationBar Opacity="1">
            <shell:ApplicationBar.MenuItems>
                <shell:ApplicationBarMenuItem Text="URI로 이동.."/>
                <shell:ApplicationBarMenuItem Text="설정"/>
            </shell:ApplicationBar.MenuItems>
        </shell:ApplicationBar>
    </phone:PhoneApplicationPage.ApplicationBar>
    <toolkit:TransitionService.NavigationInTransition>
        <toolkit:NavigationInTransition>
            <toolkit:NavigationInTransition.Backward>
                <toolkit:SlideTransition Mode="SlideRightFadeIn"/>
            </toolkit:NavigationInTransition.Backward>
            <toolkit:NavigationInTransition.Forward>
                <toolkit:SlideTransition Mode="SlideLeftFadeIn"/>
            </toolkit:NavigationInTransition.Forward>
        </toolkit:NavigationInTransition>
    </toolkit:TransitionService.NavigationInTransition>
    <toolkit:TransitionService.NavigationOutTransition>
        <toolkit:NavigationOutTransition>
            <toolkit:NavigationOutTransition.Backward>
                <toolkit:SlideTransition Mode="SlideRightFadeOut"/>
            </toolkit:NavigationOutTransition.Backward>
            <toolkit:NavigationOutTransition.Forward>
                <toolkit:SlideTransition Mode="SlideLeftFadeOut"/>
            </toolkit:NavigationOutTransition.Forward>
        </toolkit:NavigationOutTransition>
    </toolkit:TransitionService.NavigationOutTransition>
</phone:PhoneApplicationPage>